package QL;

import java.util.List;
import java.util.ArrayList;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class ButlerGetGlobalResourceStatResponse extends BaseQLResponse
{
    /// <summary>
    /// 资源统计列表
    /// </summary>
    public List<ButlerResourceStatItem> StatItems;

    /// <summary>
    /// 资源存量列表
    /// </summary>
    public List<ButlerResourceStockItem> StockItems;

    /// <summary>
    /// 每个游戏的房间水位相关统计列表
    /// </summary>
    public List<ButlerGameRoomPlatformStat> GamePlatformItems;

    @Override
    public void DeserializeFromJson(JSONObject jsonObj)
    {
        JSONObject t = jsonObj.getJSONObject("error_response");
        if (t != null && !t.isNullObject())
        {
            ErrCode = t.getString("code");
            ErrMsg = t.getString("msg");
        }
        else
        {
            t = jsonObj.getJSONObject("butler_get_global_resource_stat_response");
            StatItems = new ArrayList<ButlerResourceStatItem>();
            JSONArray arrStatItems = t.getJSONObject("stat_items").getJSONArray("butler_resource_stat_item");
            for (int i = 0; i < arrStatItems.size(); ++i)
            {
                ButlerResourceStatItem o = new ButlerResourceStatItem();
                o.DeserializeFromJson(arrStatItems.getJSONObject(i));
                StatItems.add(o);
            }
            StockItems = new ArrayList<ButlerResourceStockItem>();
            JSONArray arrStockItems = t.getJSONObject("stock_items").getJSONArray("butler_resource_stock_item");
            for (int i = 0; i < arrStockItems.size(); ++i)
            {
                ButlerResourceStockItem o = new ButlerResourceStockItem();
                o.DeserializeFromJson(arrStockItems.getJSONObject(i));
                StockItems.add(o);
            }
            GamePlatformItems = new ArrayList<ButlerGameRoomPlatformStat>();
            JSONArray arrGamePlatformItems = t.getJSONObject("game_platform_items").getJSONArray("butler_game_room_platform_stat");
            for (int i = 0; i < arrGamePlatformItems.size(); ++i)
            {
                ButlerGameRoomPlatformStat o = new ButlerGameRoomPlatformStat();
                o.DeserializeFromJson(arrGamePlatformItems.getJSONObject(i));
                GamePlatformItems.add(o);
            }
        }
    }
}
